#include"list.h"
quad* which_quad(){
    int i = rand()%5 ;
    quad * q;
    double a = double(rand()%10+1);
    double b = double(rand()%10+1);
    double c = double(rand()%10+1);
    switch (i){
        case 0:
        q = new para(a,b);
        break;
        case 1:
        q = new trap(a,b,c);
        break;
        case 2:
        q = new rect(a,b);
        break;
        case 3:
        q = new diam(a,b);
        break;
        case 4:
        q = new square(a);
        break;
    }
    return q;
}

int main(){
    int a=1;
    int all = 0,right = 0;
    list *l = new list();
    cout<<"Let's go!!! (calculate the square) (type 0 to exit)"<<endl;
    quad * q;
    while(a!=0){
        q = which_quad();
        q->showinfo();
        cout<<"enter your anser:  ";
        cin>>a;
        if(a == q->area()){
            cout<<"this is the right answer!!! "<<endl;
            q->anser = a;
            right++;
            q->result = 'V';
        }
        else if( a != 0){  
            cout<<"sorry you make a mistake... "<<endl;
            q->anser = a;
            q->result = 'X';
        }
        all++;
        cout<<endl;
        l->push(q);
    }
    cout<<"Lets review!!!"<<endl;
    for(list::iterator i =l->begin();i!=l->end();++i){
        i.print();
    }
    cout<<"Total : "<<all-1<<"     Correct :  "<<right<<endl;
}